//
//  CSprite.h
//  ResidentEvil
//
//  Created by Nguyen Tri Chung on 1/6/15.
//
//

#ifndef __ResidentEvil__CSprite__
#define __ResidentEvil__CSprite__

#include <stdio.h>

#include "../global/global.h"
#include "../util/util.h"

USING_NS_CC;

class CSprite : public Sprite {
    CC_SYNTHESIZE(string, spriteType, SpriteType); // how identify each sprite
private:
    Action* runningAction;
    Map<string, Action*>* retainedActions; // contains retained action along to csprite
public:
    CSprite(string spriteType);
    ~CSprite() override;
    
    bool init() override;
    bool initWithFile(const string& filename) override;
    bool initWithSpriteFrameName(const string& spriteFrameName) override;
    void initWithIdentifier(const string& identifier);
    
    Action* createFrameCaheAction(string& pattern, int count, float duration, bool loop);
    void retainAction(Action* actionValue, string actionKey);
    
    void bind(string pattern, float duration = -1);
    void play(string action);
    void playLoop(string action);
};

#endif /* defined(__ResidentEvil__CSprite__) */
